#!/bin/bash

# 临时启用忽略广播ICMP请求
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

# 永久启用忽略广播ICMP请求
if grep -q "^net.ipv4.icmp_echo_ignore_broadcasts" /etc/sysctl.conf; then
    sed -i 's/^net.ipv4.icmp_echo_ignore_broadcasts.*/net.ipv4.icmp_echo_ignore_broadcasts=1/' /etc/sysctl.conf
else
    echo "net.ipv4.icmp_echo_ignore_broadcasts=1" >> /etc/sysctl.conf
fi

# 应用配置
sysctl -p >/dev/null 2>&1

echo "广播ICMP请求忽略配置完成"